<?php
/**
 * Created by PhpStorm.
 * Author: ls
 * Time: 2023/8/31 9:41
 * Desc: 订单确认-企业微信
 */
class Listener_Order_Confirmed_Qywx extends Listener_Base
{
    public function handle($args)
    {
        $self       = new self();
        $self->args = $args;
        //判断队列是否开启,如果开启则把任务推送到队列
        if ($self->queue_status) {
            //推送到队列执行
            Queue::in('default', Listener_Order_Confirmed_Qywx::class, $args);
        } else {
            $self->perform();
        }

    }

    public function perform()
    {
        $args      = $this->args;
        $order    = $args['order'];
        if ($order) {
            $result = St_QywxService::send_product_order_qywx(St_NoticeCommon::PRODUCT_ORDER_CONFIRMED, $order);
            St_Log::write('企业微信',array( 'ordersn' => $order['ordersn'], 'result'=> $result), 'event/order_confirmed/log');
        }
    }

}